package com.github.cakin.shiro.chapter22.service;

import com.github.cakin.shiro.chapter22.dao.OrganizationDao;
import com.github.cakin.shiro.chapter22.entity.Organization;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @className: OrganizationService
 * @description: 组织服务
 * @date: 2020/5/25
 * @author: cakin
 */
@Service
public class OrganizationServiceImpl implements OrganizationService {
    /**
     * 注入组织Dao
     */
    @Autowired
    private OrganizationDao organizationDao;

    /**
     * 功能描述：创建组织
     *
     * @param organization 组织
     * @return Organization 组织
     * @author cakin
     * @date 2020/5/25
     */
    public Organization createOrganization(Organization organization) {
        return organizationDao.createOrganization(organization);
    }

    /**
     * 功能描述：更新组织
     *
     * @param organization 组织
     * @return Organization 组织
     * @author cakin
     * @date 2020/5/25
     */
    public Organization updateOrganization(Organization organization) {
        return organizationDao.updateOrganization(organization);
    }

    /**
     * 功能描述：根据组织Id删除组织
     *
     * @param organizationId 组织Id
     * @author cakin
     * @date 2020/5/25
     */
    public void deleteOrganization(Long organizationId) {
        organizationDao.deleteOrganization(organizationId);
    }

    /**
     * 功能描述：根据组织Id查找一个组织
     *
     * @param organizationId 组织Id
     * @return Organization 组织
     * @author cakin
     * @date 2020/5/25
     */
    public Organization findOne(Long organizationId) {
        return organizationDao.findOne(organizationId);
    }

    /**
     * 功能描述：查找组织列表
     *
     * @author cakin
     * @return List<Organization> 组织结构列表
     * @date 2020/5/25
     */
    public List<Organization> findAll() {
        return organizationDao.findAll();
    }

    /**
     * 功能描述：查找被排除的组织
     *
     * @param excludeOraganization 被排除组织
     * @author cakin
     * @return Object
     * @date 2020/5/25
     */
    public List<Organization> findAllWithExclude(Organization excludeOraganization) {
        return organizationDao.findAllWithExclude(excludeOraganization);
    }

    /**
     * 功能描述：变更组织结构
     *
     * @param source 变更前组织
     * @param target 变更后组织
     * @author cakin
     * @date 2020/5/25
     */
    public void move(Organization source, Organization target) {
        organizationDao.move(source, target);
    }
}
